package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:默认放到数组的最后一个位置
 * User: 晓星航
 * Date: 2022-11-29
 * Time: 8:56
 */

public class AddOperation implements IOperation{
    @Override
    public void work(BookList bookList) {
        System.out.println("新增图书！");
        System.out.println("请输入新增图书的名字：");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();
        System.out.println("请输入新增图书作者：");
        String author = scanner.nextLine();
        System.out.println("请输入新增图书类型：");
        String type = scanner.nextLine();
        System.out.println("请输入新增图书价格：");
        int price = scanner.nextInt();
        Book book = new Book(name,author,price,type);
        int size = bookList.getUsedSize();
        bookList.setBook(size,book);
        bookList.setUsedSize(size + 1);
        System.out.println("新增图书成功！");
    }

}
